﻿<navigation:Page x:Class="Mal.Balades.Admin.Views.VisitViews.Dashboard.Main" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:viewmodels="clr-namespace:Mal.Balades.Admin.ViewModels.VisitViewModels.Dashboard" 
           xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Visits Page">
    <navigation:Page.DataContext>
        <viewmodels:VisitsDashBoardViewModel />
    </navigation:Page.DataContext>
    <Grid x:Name="LayoutRoot" >
        <Grid.Resources>
            <Style x:Key="SearchTextBlock" TargetType="TextBlock">
                <Setter Property="Margin" Value="0,0,10,0" />
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>

            <Style x:Key="SearchTextBox" TargetType="TextBox">
                <Setter Property="Margin" Value="0,0,10,0" />
                <Setter Property="Height" Value="20" />
            </Style>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition  Width="300" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Grid.Column="0">
            <ListBox ItemsSource="{Binding Filters}"
                     SelectedItem="{Binding SelectedFilter, Mode=TwoWay}"
                     >
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Label}" FontWeight="Bold"/>
                            <TextBlock Margin="2,0,0,0" Text="{Binding Count,StringFormat='({0})'}" />
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                <TextBlock Text="Recherche" Style="{StaticResource SearchTextBlock}"  />
                <TextBox Text="{Binding SearchedText, Mode=TwoWay}" Width="200" KeyUp="TextBox_KeyUp" />
            </StackPanel>
        </StackPanel>
        <data:DataGrid x:Name="visits" Grid.Row="0" Grid.Column="1"
                       Margin="0,00,0,0" AutoGenerateColumns="False" 
             ItemsSource="{Binding VisitsToDisplay, Mode=TwoWay}"  >
            <data:DataGrid.Columns>
                <data:DataGridTemplateColumn>
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Button Command="{Binding EditCommand}" 
                                        Content="Modifier" CommandParameter="{Binding}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTextColumn Header="Titre" Binding="{Binding SourceVisit.Title}" />
                <data:DataGridTemplateColumn Header="Visible">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.Visible, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.Visible, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                
                <data:DataGridTemplateColumn Header="Résumé">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualitySumUp, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualitySumUp, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
               
                <data:DataGridTemplateColumn Header="Texte">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualityText, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualityText, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Header="Categories">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualityCategories, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualityCategories, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Header="Gps">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualityGps, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualityGps, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Informations">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualityInformations, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualityInformations, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTemplateColumn Header="Photos">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Rectangle Width="20" Height="20" Fill="Green" 
                                           Visibility="{Binding SourceVisit.QualityPictures, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                <Rectangle Width="20" Height="20" Fill="Red" 
                                           Visibility="{Binding SourceVisit.QualityPictures, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=inverse}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
            </data:DataGrid.Columns>
        </data:DataGrid>

        <Border Grid.Row="1">
            <StackPanel Orientation="Horizontal">
                <StackPanel.Resources>
                    <Style TargetType="Button">
                        <Setter Property="Margin" Value="10,5,0,5" />
                    </Style>
                </StackPanel.Resources>
                <Button Command="{Binding AddCommand}" Content="Nouvelle visite" 
                        IsEnabled="{Binding SelectedTab.AddCommandEnabled}" />
            </StackPanel>
        </Border>

        <Border Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibilityConverter}}" Background="Gray" Opacity="0.5">
            <TextBlock Text="Chargement..." FontSize="40" Foreground="White" 
                       VerticalAlignment="Center" HorizontalAlignment="Center"  />
        </Border>
        <!--<ListBox ItemsSource="{Binding Visits}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Title}" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>-->
        
        
    </Grid>
</navigation:Page>
